package com.ninthgroup.controller;

import com.ninthgroup.entity.Role;
import com.ninthgroup.service.RoleService;
import com.ninthgroup.vo.Result;
import com.ninthgroup.vo.RoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：1452863884@qq.com rcg
 * @date ：Created in 2022/10/15 13:37
 * @description：角色的控制层
 * @modified By：
 * @version:1.0
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @PostMapping("/all")
    public Result all(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize,
                      @RequestBody RoleVo roleVo){
        return roleService.findByCondition(currentPage,pageSize,roleVo);
    }


    @GetMapping("/list")
    public Result list(Integer dId){
        return roleService.findByDoctorId(dId);
    }

    @PostMapping("qr")
    public Result qr(Integer dId,Integer[] roleIds){

        return  roleService.qr(dId,roleIds);
    }


    @GetMapping("/del")
    public Result delete(Integer roleId){

        return roleService.deleteRole(roleId);
    }

    @PostMapping ("/update")
    public Result update(@RequestBody Role role){

        return roleService.updateRole(role);
    }

}